import java.io.*;
import java.util.ArrayList;

public class sort {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("test\\sort.txt"),"utf-8"));
        ArrayList<String> sort = new ArrayList<>();
        String line;

        while((line=br.readLine())!=null&&!line.equals("")){
            sort.add(line);
        }
        for(int i=0;i<sort.size();i++){
            for(int j=i+1;j<sort.size();j++){
                if(sort.get(i).charAt(0)>sort.get(j).charAt(0)){
                    swap(sort,i,j);
                }
            }
        }
        System.out.println(sort);
    }
    private static void swap(ArrayList<String> sort,int i,int j){
        String s=sort.get(i);
        sort.set(i,sort.get(j));
        sort.set(j,s);
    }
}
